package com.andy.qhb.game;

import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

import com.google.common.collect.Lists;

public class RobotManager {


	private static List<GameUser> robots = Lists.newArrayList();
	
	private static List<GameUser> miansi = Lists.newArrayList();
	
	private static AtomicInteger index = new AtomicInteger(0);
	
	private static AtomicInteger mindex = new AtomicInteger(0);
	
	public static GameUser getRobot(){
		int curi = index.getAndIncrement();
		GameUser robot = robots.get(curi%robots.size());
		if(robot.getGameInfo().getCoin() < 100000) {
			GameUtils.userCoinLog(robot, 1000000, 14, robot.getGameInfo().getCoin());
		}
		return robot;
	}
	
	public static List<GameUser> getRobots(){
		return robots;
	}
	
	public static GameUser getMiansi(){
		int curi = mindex.getAndIncrement();
		GameUser robot = miansi.get(curi%miansi.size());
		return robot;
	}
	
	public static void init(GameUser gameUser) {
		if(gameUser.getUser().getRole() == 1) {
			robots.add(gameUser);
		}else if(gameUser.getUser().getRole() == 2) {
			miansi.add(gameUser);
		}
		
	}

	
	
}
